package com.example.email.controller;


import com.example.email.entity.Mailexplain;
import com.example.email.service.MailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api")
public class MailRestController {

    @Autowired
    MailService mailService;

    /**
     * 改变多封邮件状态
     * @param mailnumber
     * @return
     */
    @PostMapping("/updateMailStatus")
    public int updateMailStatus(@RequestParam int [] mailnumber,@RequestParam("mailstatus") int mailstatus){
            return mailService.updateMailStatus(mailnumber,mailstatus);
    }

    /**
     * 将多封邮件修改为星标邮件
     * @param mailnumber
     * @return
     */
    @PostMapping("/updateMailStarMarks")
    public int updateMailStarMarks(@RequestParam int [] mailnumber){
        return mailService.updateMailStarMarks(mailnumber);
    }


    /**
     * 将多封邮件取消星标邮件
     * @param mailnumber
     * @return
     */
    @PostMapping("/updateMailStarMarks0")
    public int updateMailStarMarks0(@RequestParam int [] mailnumber){
        return mailService.updateMailStarMarks0(mailnumber);
    }

    /**
     * 取消或标记星标邮件
     * @param ifStarmarker
     * @param mailnumber
     * @return
     */
    @PostMapping("/updateMailStarMark/{ifStarmarker}/{mailnumber}")
    public int updateMailStarMark(@PathVariable int ifStarmarker,@PathVariable int mailnumber){
        return mailService.updateMailStarMark(ifStarmarker,mailnumber);
    }


    /**
     * 将邮箱丢入垃圾箱
     * @param mailnumber
     * @param mailstatus
     * @return
     */
    @PostMapping("/updateMailStatus5")
    public int updateMailStatus5(@RequestParam int [] mailnumber, int mailstatus){
        return mailService.updateMailStatus5(mailnumber,mailstatus);
    }

    /**
     * 将本页所有邮件变为已读
     * @param mailnumber
     * @return
     */
    @PostMapping("/updateIfReadMail")
    public int updateIfReadMail(@RequestParam int [] mailnumber){
        return mailService.updateIfReadMail(mailnumber);
    }




    @PostMapping("/updateIfReadMails")
    public int updateIfReadMails(@RequestParam int [] mailnumber,@RequestParam int  ifRead){
        return mailService.updateIfReadMails(mailnumber,ifRead);
    }
}
